unit PassLookUpForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, PBCheckLB, globals;

type
  TPassLookUpScreen = class(TForm)
    Panel1: TPanel;
    Label5: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    OpenDialog1: TOpenDialog;
    allPassesList: TPBCheckListBox;
    procedure Button3Click(Sender: TObject);
    procedure allPassesListClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    SelectedPassname : String;
  public
    { Public declarations }
    function get_SelectedPassName(Var spn : String) : Boolean;
  end;

var
  PassLookUpScreen: TPassLookUpScreen;

implementation

uses referenceAnotherForm;

{$R *.dfm}

procedure TPassLookUpScreen.Button3Click(Sender: TObject);
var
  f : TextFile;
  i, size : Integer;
  s : String;
begin
allPassesList.Clear;
if OpenDialog1.Execute then
  begin
    assignFile(f, OpenDialog1.FileName);
    if FileExists(OpenDialog1.FileName) then
       reset(f);
    while not EOF(f) do
      begin
        Readln(f, s); // passName
        allPassesList.items.Add(s);
        Readln(f, s); // pass kernel Name
        Readln(f, size); // size of subdomain
        for i:=0 to size-1 do
          Readln(f, s); // skip line
        Readln(f, s); // skip line seperator
      end;
    closeFile(f);
  end;
end;

procedure TPassLookUpScreen.allPassesListClick(Sender: TObject);
var
  tmp : String;
begin
if countChecked(allPassesList, tmp) > 1 then
  begin
    showMessage('Only One Kernel selection is allowed');
    allPassesList.State[allPassesList.ItemIndex] := cbUnchecked;
  end;
end;

procedure TPassLookUpScreen.Button2Click(Sender: TObject);
begin
if allPassesList.State[allPassesList.ItemIndex] = cbChecked then
  begin
    SelectedPassName := allPassesList.Items.Strings[allPassesList.ItemIndex];
    close;
  end
else
  showMessage('You should Select a Pass First .....');
end;

procedure TPassLookUpScreen.Button1Click(Sender: TObject);
begin
selectedPassName := '';
close;
end;

function TPassLookUpScreen.get_SelectedPassName(Var spn : String) : Boolean;
begin
if SelectedPassname = '' then
  result := false
else
  begin
    spn := SelectedPassname;
    result := true;
  end;
end;

end.
